var t = getApp();

Page({
    data: {
        active: 0,
        listData: [],
        tabNav: [],
        coupon: !1,
        isvip: !1,
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        var a = wx.getStorageSync("yz_basic_info").plugin_setting.debt_shop || {};
        t.debtId && this.setData({
            debtId: t.debtId
        }), t.coupon ? (this.setData({
            coupon: !0
        }), this.setData({
            tabNav: [ "全部", "".concat(a.common_credit_name ? a.common_credit_name : "消费账户"), "".concat(a.frozen_credit_name ? a.frozen_credit_name : "锁定账户") ]
        }), wx.setNavigationBarTitle({
            title: "提货券明细"
        })) : t.isvip ? (this.setData({
            tabNav: [],
            isvip: !0
        }), wx.setNavigationBarTitle({
            title: "提货券明细"
        })) : (this.setData({
            tabNav: [ "全部", "采购金", "网店收入" ]
        }), wx.setNavigationBarTitle({
            title: "采购款明细"
        })), this.getData();
    },
    init: function() {
        this.setData({
            isLoadMore: !0,
            page: 1,
            total_page: 0,
            listData: []
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    onShareAppMessage: function() {},
    changeTap: function(t) {
        var a = t.detail.index;
        this.setData({
            active: a
        }), this.init(), this.getData();
    },
    getData: function() {
        var a = this, e = {
            amount_type: ""
        };
        this.data.coupon ? 0 == this.data.active ? e.amount_type = [ 1, 2 ] : 1 == this.data.active ? e.amount_type = "2" : 2 == this.data.active && (e.amount_type = "1") : this.data.isvip ? e.amount_type = "2" : 0 == this.data.active ? e.amount_type = [ 3, 4, 5 ] : 1 == this.data.active ? e.amount_type = "3" : 2 == this.data.active && (e.amount_type = [ 4, 5 ]), 
        this.data.debtId && (e.debtor_id = this.data.debtId);
        var i = t.getNetAddresss("plugin.debt-shop.frontend.debt-member.creditLog");
        t._postNetWork({
            url: i,
            data: e,
            success: function(t) {
                var e = t.data;
                1 == e.result && (a.data.isLoadMore = !0, a.data.total_page = e.data.last_page, 
                a.data.total_page || (a.data.total_page = 0), a.setData({
                    listData: e.data.data
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var a = this, e = "";
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page = this.data.page + 1;
            var i = {
                amount_type: "",
                page: this.data.page
            };
            this.data.coupon ? 0 == this.data.active ? i.amount_type = [ 1, 2 ] : 1 == this.data.active ? i.amount_type = "2" : 2 == this.data.active && (i.amount_type = "1") : this.data.isvip ? i.amount_type = "2" : 0 == this.data.active ? i.amount_type = [ 3, 4, 5 ] : 1 == this.data.active ? i.amount_type = "3" : 2 == this.data.active && (i.amount_type = [ 4, 5 ]), 
            this.data.debtId && (i.debtor_id = this.data.debtId), e = t.getNetAddresss("plugin.debt-shop.frontend.debt-member.creditLog"), 
            t._postNetWork({
                url: e,
                data: i,
                success: function(t) {
                    var e = t.data;
                    1 == e.result ? (a.data.isLoadMore = !0, a.setData({
                        listData: a.data.listData.concat(e.data.data)
                    })) : (a.data.page = a.data.page - 1, a.isLoadMore = !1, wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    }));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    }
});